home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ecstr3.arc / MEMRCHR.C < prev    next >
C/C++ Source or Header  |  1987-03-04  |  763b  |  28 lines

  1. /*  File   : memrchr.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 25 May 1984
  4.     Defines: memrchr()
  5.  
  6.     memrchr(src, chr, len)
  7.     searches the memory area pointed to by src extending for len bytes,
  8.     looking for an occurrence of the byte value chr.  It returns NullS
  9.     if there is no such occurrence.  Otherwise it returns a pointer to
  10.     the LAST such occurrence.
  11.  
  12.     See the "Character Comparison" section in the READ-ME file.
  13. */
  14.  
  15. #include "strings.h"
  16.  
  17. char *memrchr(src, chr, len)
  18.     register char *src;
  19.     register int chr;          /* should be char */
  20.     register int len;
  21.     {
  22.        register char *ans;
  23.        for (ans = NullS; --len >= 0; src++)
  24.            if (*src == chr) ans = src;
  25.        return ans;
  26.     }
  27.  
  28.